﻿using System.Collections.Generic;

namespace AOT.Game.ID
{
    public class IdPool
    {
        private List<int> _idPoolList;

        public IdPool(int wordId,int poolSize)
        {
            _idPoolList = GetPanelIdPool(wordId, poolSize);
        }

        public int GetId()
        {
            int id = _idPoolList[0];
            _idPoolList.RemoveAt(0);
            return id;
        }


        public void ReturnId(int id)
        {
            _idPoolList.Add(id);
        }

        public void ReturnId(long id)
        {
            int t = (int)id;
            _idPoolList.Add(t);
        }
        
        #region 功能函数

        private List<int> GetPanelIdPool(int wordId, int poolSize)
        {
            List<int> resList = new List<int>(poolSize);
            for (int i = 0; i < poolSize; i++)
            {
                resList.Add(i);
            }

            return resList;
        }

        #endregion
    }
}